<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src='/restful/js/jquery.min.js'></script>
</head>
<body>
  <h1>Restful GET请求</h1>
  <a href='/restful/api/student?stid=18'>GET 请求</a>
  
  <h1>Restful POST请求</h1>
  <form action="/restful/api/student" method="post">
    <input type="text" name="stid" />
    <input type="text" name="name" />
  	<input type="submit" value="测试" />
  </form>
  
  <h1>Restfull DELETE</h1>
  <button onclick="testdel()">测试</button>
  
   <h1>Restfull PUT</h1>
   <button onclick="testput()">测试</button>
  
</body>
<script>
function testdel(){
	var obj={"stid":20,"name":"提莫"};
	$.ajax({
	    type : 'delete',
	    data : JSON.stringify(obj),
	    url : '/restful/api/student',
	    contentType : 'application/json;charset=UTF-8',
	    dataType : 'json',
	    success : function(data,textStatus,jqXHR){
	       alert(data);
	    }
	});
	 
}

function testput(){
	var obj={"stid":20,"name":"提莫put"};
	$.ajax({
	    type : 'put',
	    data : JSON.stringify(obj),
	    url : '/restful/api/student',
	    contentType : 'application/json;charset=UTF-8',
	    dataType : 'json',
	    success : function(data,textStatus,jqXHR){
	       alert(data);
	    }
	});
	 
}
</script>
</html>